﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using PMSA.Framework.Database;

/// <summary>
/// Summary description for CGroupProductFacade
/// </summary>
public class CGroupProductFacade
{
    private GroupProductDAL db = new GroupProductDAL();
    public IList<GroupProduct> List(int pageIndex, int pageMax, int groupProductId, int groupParent, int isActive)
    {
        IList<GroupProduct> list = null;
        DataSet ds = new DataSet();
        ds = db.List(pageIndex, pageMax, groupProductId, groupParent, isActive);
        if (ds != null && ds.Tables.Count > 0)
        {
            list = CDb.MapList<GroupProduct>(ds.Tables[0]);
        }

        return list;
    }
    public GroupProduct Detail(int groupProductId)
    {
        DataSet ds = new DataSet();
        ds = db.Detail(groupProductId);
        GroupProduct obj = CDb.Map<GroupProduct>(ds.Tables[0]);
        return obj;
    }
    public GroupProduct Update(int groupProductId, string groupProductName, int isActive, int groupParent, int status)
    {
        DataSet ds = new DataSet();
        ds = db.Update(groupProductId, groupProductName, isActive, groupParent, status);
        GroupProduct obj = CDb.Map<GroupProduct>(ds.Tables[0]);
        return obj;
    }
    public GroupProduct Insert(string groupProductName, int isActive, int groupParent, int status)
    {
        DataSet ds = new DataSet();
        ds = db.Insert(groupProductName, isActive, groupParent, status);
        GroupProduct obj = CDb.Map<GroupProduct>(ds.Tables[0]);
        return obj;
    }
    public GroupProduct UpdateStatusActive(int groupProductId, int isActive)
    {
        DataSet ds = new DataSet();
        ds = db.UpdateStatusActive(groupProductId, isActive);
        GroupProduct obj = CDb.Map<GroupProduct>(ds.Tables[0]);
        return obj;
    }
}